import 'package:flutter/material.dart';

import '../model/home_model.dart';

// 购物车
class Shopcart extends StatefulWidget {
  const Shopcart({Key? key}) : super(key: key);
  @override
  State<Shopcart> createState() => _ShopcartState();
}

class _ShopcartState extends State<Shopcart> {
  
  final ScrollController _controller = ScrollController();

  // 商品集合
  var goodsLit = [
    {"url": "images/1.jpeg", "price": 69, "title": "纱布尿布","desc":"商品描述"},
    {"url": "images/2.jpeg", "price": 129, "title": "婴儿包被","desc":"商品描述"},
    {"url": "images/3.jpeg", "price": 57, "title": "洗脸巾","desc":"商品描述"},
    {"url": "images/4.jpeg", "price": 269, "title": "睡衣","desc":"商品描述"},
    {"url": "images/5.jpeg", "price": 188, "title": "五色毛巾","desc":"商品描述"},
    {"url": "images/6.jpeg", "price": 58, "title": "婴儿毛巾","desc":"商品描述"},
    {"url": "images/7.jpeg", "price": 3990, "title": "床上用品","desc":"商品描述"},
    {"url": "images/8.jpeg", "price": 68, "title": "抹布","desc":"商品描述"},
    {"url": "images/9.jpeg", "price": 78, "title": "洁面巾","desc":"商品描述"},
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
          child: Column(
        children: [
           ShowGoosList(
            goods: goodsLit,
            controller: _controller,
          )
        ],
      )),
    );
  }


// 商品
//   Widget get _goods {
//     return Container(
//         child: Column(
//       children: goodsLit.map((Map map) {
//         return Container(
//             width: double.infinity,
//             height: 130,
//             margin: const EdgeInsets.fromLTRB(10, 10, 10, 0),
//             child: Column(
//               children: [
//                 Row(
//                   // 排序顺序
//                   textDirection: TextDirection.ltr,
//                   // 开始方向 若mainAxisSize为min则没有意义
//                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
//                   // mainAxisSize: MainAxisSize.min,
//                   // 纵轴默认居中
//                   crossAxisAlignment: CrossAxisAlignment.center,
//                   children: [
//                     Expanded(
//                       child: Image.asset(
//                         map["url"],
//                         fit: BoxFit.cover,
//                         // 图片不重复
//                         repeat: ImageRepeat.noRepeat,
//                       ),
//                       flex: 1,
//                     ),
//                     const SizedBox(
//                       width: 20,
//                     ),
//                     Expanded(
//                       child: Column(
//                         // 主轴对其方式
//                         mainAxisAlignment: MainAxisAlignment.center,
//                         // 横轴对齐方式
//                         crossAxisAlignment: CrossAxisAlignment.start,
//                         children: [
//                           Text(
//                             map["title"],
//                             style: const TextStyle(
//                               fontSize: 26,
//                               fontWeight: FontWeight.bold,
//                             ),
//                           ),
//                           Text(
//                             "￥" + map["price"].toString(),
//                             style: const TextStyle(
//                               fontSize: 20,
//                               color: Colors.red,
//                             ),
//                           )
//                         ],
//                       ),
//                       flex: 2,
//                     )
//                   ],
//                 ),
//                 const SizedBox(
//                   width: double.infinity,
//                   height: 5,
//                 ),
//                 const Divider(
//                   height: 1.0,
//                   indent: 0.0,
//                   color: Colors.grey,
//                 )
//               ],
//             ));
//       }).toList(),
//     ));
//   }
}
